package cn.vshare.util;

import org.apache.log4j.Logger;
import org.apache.log4j.MDC;

public class LogUtil {

    /**
     * 向数据库写入日志
     * @param clazz 需要写入数据库的类
     * @param userid 当前用户的id
     * @param ip 用户的ip地址
     * @param msg 消息记录
     */
    public static void doLog(Class clazz, String userid, String ip, String msg) {
        Logger log = Logger.getLogger(clazz);
        MDC.put("uid",userid);
        MDC.put("ip",ip);
        log.info(msg);
    }
}
